package com.njuptB180316.boki.dao;

import com.njuptB180316.boki.dataobject.Record;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface RecordMapper {
    @Insert({
        "insert into record (phone, id, ",
        "gmt_created)",
        "values (#{phone,jdbcType=BIGINT}, #{id,jdbcType=INTEGER}, ",
        "#{gmtCreated,jdbcType=BIGINT})"
    })
    int insert(Record record);

    @Select({
        "select",
        "phone, id, gmt_created",
        "from record"
    })
    @Results({
        @Result(column="phone", property="phone", jdbcType=JdbcType.BIGINT),
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.BIGINT)
    })
    List<Record> selectAll();

    @Select({
            "select",
            "phone, id, gmt_created",
            "from record",
            "where phone = #{phone,jdbcType=BIGINT}"
    })
    @Results({
            @Result(column="phone", property="phone", jdbcType=JdbcType.BIGINT),
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER),
            @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.BIGINT)
    })
    List<Record> selectByPhone(long phone);

    @Delete({
            "delete FROM record",
            "WHERE phone = #{phone,jdbcType=BIGINT} AND gmt_created = #{gmt_created,jdbcType=BIGINT}"
    })
    int delete(@Param("phone") long phone, @Param("gmt_created") long gmt_created);
}